Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.NodePoolMag = undefined;
var LogManager = require("AA_LogManager");
var NodePoolMag = function () {
  function _creator() {
    this.saveNode = {};
    this.savePrefab = {};
  }
  Object.defineProperty(_creator, "instance", {
    get: function () {
      return this.nodepool;
    },
    enumerable: false,
    configurable: true
  });
  _creator.prototype.createNodeCount = function (e, t, o, i) {
    var a = this.saveNode[e];
    if (a) {
      LogManager.LogMgr.debug("对象池已经创建");
    } else {
      a = new cc.NodePool(i);
      this.saveNode[e] = a;
      this.savePrefab[e] = o;
      for (var r = 0; r < t; r++) {
        var c = cc.instantiate(o);
        a.put(c);
      }
    }
  };
  _creator.prototype.getNode = function (e) {
    var t = this.saveNode[e];
    var o = null;
    if (t) {
      if (t.size() > 0) {
        o = t.get();
      } else {
        var n = this.savePrefab[e];
        n && n.isValid && (o = cc.instantiate(n));
      }
      return o;
    }
    return null;
  };
  _creator.prototype.recycleNode = function (e, t) {
    var o = this.saveNode[e];
    if (o) {
      t.isValid && o.put(t);
    } else {
      LogManager.LogMgr.debug("节点池不存在", e);
    }
  };
  _creator.prototype.clearAllNode = function () {
    for (var e in this.saveNode) this.clearNode(e);
  };
  _creator.prototype.clearNode = function (e) {
    var t = this.saveNode[e];
    if (t) {
      t.clear();
      delete this.saveNode[e];
      delete this.savePrefab[e];
    }
  };
  _creator.nodepool = new _creator();
  return _creator;
}();
exports.NodePoolMag = NodePoolMag;